#include "Text.h"

Text::Text(const Position& position, const std::string& text, unsigned int size, const Color& color)
        : GraphicalElement(), fontSize(size), textColor(color)
{
    setPosition(position);
    setText(text);
}

Text::Text(long id, const Position& position, const std::string& text, unsigned int size, const Color& color)
        : GraphicalElement(id), fontSize(size), textColor(color)
{
    setPosition(position);
    setText(text);
}

void Text::setText(std::string newText)
{
    std::string str = newText.empty() ? " " : newText;
    deleteTexture();
    setTexture(GraphicsWrapper::createText(str, fontSize, textColor));
}

int Text::getFontSize()
{
    return fontSize;
}

void Text::setColor(const Color& color)
{
    textColor = color;
}

Text::~Text()
{
    deleteTexture();
}
